<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../plugins/vue.min.js"></script>
    <style>
        
    </style>
</head>
<body>
    <div id="box">
        
      <!-- <home v-show=" which === 'home' "></home>
     <list v-show=" which === 'list' "></list>
      <shopcar v-show=" which === 'shopcar' "></shopcar> -->

      <!-- 可以使用动态组件来代替上面的写法 -->
      <!-- 说他是谁,他就是谁 -->
      <!-- component给的一个组件,is是里面的属性 -->
      <!-- 动态组件,切换会删掉其他的,重新创建  --- 带来的问题,没办法保存之前填写的信息了 -->
      <!-- 想要保留原来的数据,也就是下面input里面的值   ---加上keep-alive -->
      <keep-alive>
        <component :is="which"></component>
      </keep-alive>
        
      <footer>
        <ul>
            <li @click="which = 'home'">首页</li>
            <li @click="which = 'list'">列表</li>
            <li @click="which = 'shopcar'">购物车</li>
        </ul>
      </footer>


    </div>
    
    <script>
        Vue.component("home",{
            template:`
            <div>
                 home
                 <input type="search">
                 </div>
            `
        })
        Vue.component("list",{
            template:`
            <div>
               list
                 </div>
            `
        })
        Vue.component("shopcar",{
            template:`
            <div>
               shopcar
                 </div>
            `
        })
        let vm =  new Vue({
            el:"#box",
            data:{
                which:'home'
            }

        })
    </script>
</body>
</html>